package com.mezz.bones.im.logic.process.impl;

import com.mezz.bones.im.common.enums.ActionCodeEnum;
import com.mezz.bones.im.common.message.base.MessageHeader;
import com.mezz.bones.im.common.message.body.in.ConversationPrivateInfoReq;
import com.mezz.bones.im.common.message.body.out.ConversationPrivateInfoRes;
import com.mezz.bones.im.common.domain.user.ImUserConnectInfo;
import com.mezz.bones.im.logic.process.interfaces.AbstractMessageLogicProcess;
import com.mezz.bones.im.logic.service.IChatConversationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: zhuang
 * @Date: 2024/11/29 18:39
 * @Description: 获取会话中
 * @Version: 1.0
 **/

@Service
public class ConversationInfoProcess extends AbstractMessageLogicProcess<ConversationPrivateInfoReq, ConversationPrivateInfoRes> {

    @Resource
    private IChatConversationService conversationService;

    @Override
    public String tag() {
        return ActionCodeEnum.CLIENT_CONVERSATION_PRIVATE_INFO.getCode();
    }

    @Override
    public void preHandlerParam(ImUserConnectInfo senderUserConnectInfo, MessageHeader header, ConversationPrivateInfoReq req) {

        req.setUserId(senderUserConnectInfo.getUserId());
    }

    @Override
    public ConversationPrivateInfoRes process(ImUserConnectInfo senderUserConnectInfo, MessageHeader header, ConversationPrivateInfoReq req, Map<String, Object> ctx) {

        //消息已读回执 对端会话重置 最后一次已读seq
        return conversationService.getPrivateConversationInfo(req);
    }
}
